import  pymongo,Config
class DBMongo():
    def __init__(self):
        self.mongo = pymongo.MongoClient(host=Config.SERVER,port=Config.MONGO_PORT)
        self.mydb=self.mongo["AAASupermarket"]

    def SetData(self,collection=None,params=None):
        self.mycol =self.mydb[collection]
        self.mycol.insert_one(params)

    def QueryDB(self,collection=None):
        return self.mydb[collection].find_one()

# params={
    # "name":"AAAsupermarket"
# }
# dbm=DBMongo()
# dbm.SetData(collection="test",params=params)
# res=dbm.QueryDB(collection='test')
# print(res)